var mygrid ={};
$(function() {
	mygrid = jQuery("#list").jqGrid({
		url : "workflow/data/query-data!inbox",
		datatype : "json",
		mtype : 'GET',
		colNames : [ 
		             '办理',
		             '业务', 
		             '拟稿', 
		             '拟稿时间', 
		             '最后办理', 
		             '最后办理时间', 
		             '监控',
		             '[ID]流程名'
		             ],
		colModel : [ 
		{
			name : 'workflowName',
			index : 'workflowName',
			width : 90,
			formatter : nameFormater
		}, 
		{
			name : 'title',
			index : 'title',
			width : 250
		}
		,{
			name : 'starter',
			index : 'starter',
			width : 50
		}, {
			name : 'startDate',
			index : 'startDate',
			width : 200
		}, {
			name : 'sender',
			index : 'sender',
			width : 50
		}, {
			name : 'sendDate',
			index : 'lastSendDate',
			width : 200
		}, {
			name : 'workflowId',
			index : 'workflowId',
			width : 50,
			formatter : doWatchFormatter
		}, {
			name : 'workflowName',
			index : 'workflowName',
			width : 100,
			formatter:workflowFormatter
		} ],
		pager : '#pager',
		rowNum : 10,
		rowList : [ 10, 20, 30 ],
		sortname : 'lastSendDate',
		sortorder : 'desc',
		viewrecords : true,
		caption : '我的待办事项',
		width : '850',
		height : '300',
		jsonReader : {
			repeatitems : false,
			id : "0"
		}
	});
});
function nameFormater(cv, options, row) {
	var eid = row['workflowId'];
	var sid  =row['stepId'];
	var aid  =row['actionId'];
	
	
	var postData = {
		'workflowId':eid,
		'stepId':sid,
		'actionId':aid,
		'auto':false
			
	};
	var url = "workflow/proceed/proceed!prework";
	var link = $("<a style='color:green' title='点击办理'></a>");
	link
			.attr("href", "javascript:doPost('" + url + "','"+$.param(postData)+"');");
	link.html("<b>点击办理</b>");
	return link.get(0).outerHTML;

}

function dateFormatter(cv,opt,row){
	var date = formatDate(cv, "yyyy年MM月dd日 HH时mm分ss秒 E");
	return date;
}
function workflowFormatter(cv,opt,row){
	var eid = row['workflowId'];
	return "["+eid+"]"+cv;
}
